// 影院排片数据库添加
const mongoose = require('mongoose');
const { schedules } = require("./data/schedules")
//  排片集合（schedules）
const schema = new mongoose.Schema({
    movieId: { type: mongoose.Schema.Types.ObjectId, ref: "movies" },
    cinemasId: { type: mongoose.Schema.Types.ObjectId, ref: "cinemas" },
    theaterId: { type: mongoose.Schema.Types.ObjectId, ref: "projectionHall" },
    showTime: String,
    price: Number,
})

let schedulesModle = mongoose.model("schedules", schema, "schedules");
// 建立链接
mongoose.connect("mongodb://tangzhenhua:Lovo123456@182.92.214.223:8084/heshumiao",
    {
        useNewUrlParser: true,
        useUnifiedTopology: true,
        auth: { authSource: "admin" }
    },
    async () => {
        await schedulesModle.create(schedules);
        console.log(schedules);
    });